import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '借用人',
    dataIndex: 'username',
  },
  {
    title: '借用时间',
    dataIndex: 'borrowedTime',
    customRender: ({ record }) => {
      const time = record.borrowedTime;
      return time ? moment(time).format('YYYY-MM-DD') : '-';
    },
  },
  {
    title: '归还时间',
    dataIndex: 'returnTime',
    customRender: ({ record }) => {
      const time = record.returnTime;
      return time ? moment(time).format('YYYY-MM-DD') : '-';
    },
  },
  {
    title: '借用原因',
    dataIndex: 'borrowReason',
  },
  {
    title: '审批人',
    dataIndex: 'approverName',
  },
  {
    title: '审批状态',
    dataIndex: 'opinion',
    customRender: ({ record }) => {
      if (record.opinion === 0) {
        return '待审批';
      } else if (record.opinion === 1) {
        return '通过';
      } else {
        return '驳回';
      }
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'opinion',
    label: '审批状态',
    component: 'Select',
    colProps: { span: 8 },
    componentProps: {
      options: [
        {
          value: 0,
          label: '待审批',
        },
        {
          value: 1,
          label: '通过',
        },
        {
          value: 2,
          label: '驳回',
        },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'plateNumber',
    label: '车牌号',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入车牌号',
    },
  },
  {
    field: 'brand',
    label: '品牌',
    component: 'Input',
    componentProps: {
      placeholder: '请输入品牌',
    },
  },
  {
    field: 'model',
    label: '型号',
    component: 'Input',
    componentProps: {
      placeholder: '请输入型号',
    },
  },
  {
    field: 'color',
    label: '颜色',
    component: 'Input',
    componentProps: {
      placeholder: '请输入颜色',
    },
  },
  {
    field: 'type',
    label: '类别',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入类别',
    },
  },
  {
    field: 'purchaseDate',
    label: '购买时间',
    component: 'DatePicker',
    componentProps: {
      placeholder: '请选择购买时间',
      valueFormat: 'X',
    },
  },
  {
    field: 'carCondition',
    label: '车辆状况',
    component: 'Input',
    componentProps: {
      placeholder: '请输入车辆状况',
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        {
          value: 0,
          label: '空闲',
        },
        {
          value: 1,
          label: '借用',
        },
      ],
    },
  },
];
